package com.dingreading.cloud.admin.controller;

import com.dingreading.cloud.admin.entity.CooperPayOrder;
import com.dingreading.cloud.admin.service.CooperPayOrderService;
import com.dingreading.cloud.common.base.R;
import com.dingreading.cloud.common.util.PageBeanDto;
import com.dingreading.cloud.common.util.PageUtil;
import com.mybatisflex.core.paginate.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/system/cooperPayOrder")
@Api(tags = "总部-叮叮合作费支付管理")
public class CooperPayOrderController {

    @Resource
    CooperPayOrderService cooperPayOrderService;

    @ApiOperation(value = "分页列表")
    @PostMapping(value = "/pageList", produces = "application/json; charset=UTF-8")
    public R<Object> pageList(
            @ApiParam(value = "分页公共类") PageUtil pageUtil,
            @ApiParam(value = "订单号/uid/客户姓名/手机号/销售姓名") @RequestParam(value = "keyword", required = false) String keyword,
            @ApiParam(value = "支付状态 0.取消 1.已支付 2.待付款") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(value = "支付类型 1.微信 2.支付宝") @RequestParam(value = "payType", required = false) Integer payType
    ) {
        Page<CooperPayOrder> page = cooperPayOrderService.pageList(pageUtil, keyword, status, payType);

        PageBeanDto data = new PageBeanDto();
        data.setTotal(page.getTotalRow());
        data.setList(page.getRecords());
        return R.ok(data);
    }

    @ApiOperation(value = "获取订单详情")
    @PostMapping(value = "/getBean", produces = "application/json; charset=UTF-8")
    public R<Object> getById(
            @ApiParam(value = "订单id") @RequestParam(value = "id") Long id
    ) {
        CooperPayOrder data = cooperPayOrderService.getById(id);
        return R.ok(data);
    }

}